package com.sirius.meta.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author Surging
 * @version 1.0
 * @ClassName PrintWordsJob
 * @date 2022/1/18 14:58
 * @desc
 */
@PersistJobDataAfterExecution
public class PrintWordsJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        jobExecutionContext.getMergedJobDataMap().put("name", "( i + 1) + name");
        String name = jobExecutionContext.getMergedJobDataMap().getString("name");

        String printTime = new SimpleDateFormat("yy-MM-dd HH-mm-ss").format(new Date());
        System.out.println("PrintWordsJob start at:" + printTime + ", prints: Hello Job-" + new Random().nextInt(100) + name);

    }
}
